//
//  THDemoViewController.swift
//  Practise
//
//  Created by flower on 2017/8/22.
//  Copyright © 2017年 lalala. All rights reserved.
//

import UIKit

class THDemoViewController: THBaseViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 设置标题
        title = "第\(navigationController?.childViewControllers.count ?? 0)个"
    }
    
    // MARK: - 监听方法
    /// 继续 PUDH 一个新的控制器
    @objc fileprivate func showNext() {
        
        let vc = THDemoViewController()
        
        navigationController?.pushViewController(vc, animated: true)
        
    }
}

extension THDemoViewController {
    
    /// 重写父类方法
    override func setupTableView() {
        
        super.setupTableView()
        // 设置右侧的控制器
        // 1. 导航栏系统自带样式
        //navigationItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", style: .plain, target: self, action: #selector(showNext))
        // 2. 导航栏按钮自定义样式
        //let btn: UIButton = UIButton.cz_textButton("下一个", fontSize: 16, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        //btn.addTarget(self, action: #selector(showNext), for: .touchUpInside)
        //navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn)
        
        // 3. 抽取出 UIBarButtonItem
        //navigationItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", target: self, action: #selector(showNext))
        
        // 4. 自定义导航栏
        navItem.rightBarButtonItem = UIBarButtonItem(title: "下一个", target: self, action: #selector(showNext))

    }
    
}
